# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=choose
pkgver=1.2.0
pkgrel=0
pkgdesc="A human-friendly and fast alternative to cut and (sometimes) awk"
url="https://github.com/theryangeary/choose"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # limited by rust/cargo
license="GPL-3.0-or-later"
makedepends="cargo"
source="https://github.com/theryangeary/choose/archive/v$pkgver/choose-$pkgver.tar.gz"
builddir="$srcdir/choose-$pkgver"

prepare() {
	default_prepare

	# Optimize binary for size.
	cat >> Cargo.toml <<-EOF

		[profile.release]
		codegen-units = 1
		lto = true
		opt-level = "z"
		panic = "abort"
	EOF
}

build() {
	cargo build --release --locked
}

check() {
	cargo test --release
}

package() {
	cargo install --path . --root="$pkgdir/usr"
	rm "$pkgdir"/usr/.crates.*
}

sha512sums="8d7f04850f2856b7291337156f3e3a4401a8e3bae90bbac666d245a2224899ec5e2365430cb6dd49b7b561d97f15b90182b03eaef753fc26575a2529c890dc1b  choose-1.2.0.tar.gz"
